package zookeeper.curator;

import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;

import java.util.concurrent.TimeUnit;

/**
 * @author zhenzicheng
 * @DESCRIPTION: 测试类
 * @DATE: 2022/04/23 12:22 PM
 */
public class CuratorClusterBaseOperations extends CuratorClusterBase {
  @Test
  public void testCluster() throws Exception {
    CuratorFramework curatorFramework = getCuratorFramework();
    String pathWithParent = "/test";
    byte[] bytes = curatorFramework.getData().forPath(pathWithParent);
    System.out.println(new String(bytes));
    while (true) {
      try {
        byte[] bytes1 = curatorFramework.getData().forPath(pathWithParent);
        System.out.println(new String(bytes1));

        TimeUnit.SECONDS.sleep(5);
      } catch (Exception e) {
        e.printStackTrace();
        testCluster();
      }
    }
  }
}
